<template>
	<view class="flex-y-center">
		<view class="search flex flex-y-center" :style="{'background': background,'width': width+'rpx'}" @click="goto()">
			<i class="iconfont icon-sou">&#xe61f;</i>
			<input type="text" v-model="keywords" :placeholder="placeholder" :disabled="disabled" placeholder-class="font-26" @confirm.stop="searchKeywords()">
		</view>
		<view class="soubtn" v-if="page == 'list'" @click="souKeyword()">搜索</view>
	</view>
</template>

<script>
	export default {
		name:"search",
		props: {
			background: {
				type: String,
				default: '#ffffff'
			},
			placeholder:{
				type: String,
				default: '搜索'
			},
			width: {
				type: Number,
				default: 300
			},
			page: {
				type: String,
				default: '',   //mall商城   list列表页 

			}
		},
		data() {
			return {
				keywords: '',
				disabled: false,

			};
		},
		created() {
			if(this.page == 'mall') {
				this.disabled = true
			}

		},

		methods: {
			searchKeywords() {
				this.$emit('search', this.keywords)
			},
			souKeyword() {
				this.$emit('search', this.keywords)
			},
			goto() {
				if (this.page == 'mall') {
					this.$util.redirectTo('/otherpages/mall/search')
				}else {
					return
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
.search {
  padding: 22rpx 24rpx;
  height: 74rpx;
  background-color: #fff;
  border-radius: 40rpx;
  box-sizing: border-box;
  .icon-sou {
	  color: $color-title2;
	  font-size: 40rpx;
	  margin-right: 10rpx;
  }
}

.soubtn {
	width: 116rpx;
	background: $color-title2;
	color: #fff;
	border-radius: 40rpx;
	font-size: 24rpx;
	height: 64rpx;
	line-height: 64rpx;
	text-align: center;
	margin-left: 30rpx;
}
</style>